﻿using System;
using CalculatorLib;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CalculatorLib.Test
{
    
    [TestClass]
    public class MathLibTest
    {

        private MathLib _lib;


        [TestInitialize]
        public void SetupLib()
        {
            _lib = new MathLib();
        }

        [TestMethod]
        public void CanComputePercent()
        {
            float result = _lib.Percent(8, 10);
            Assert.AreEqual(80, result);
        }

        [TestMethod]
        public void NegativeIsReturnedIfTotalLessThanPart()
        {
            float result = _lib.Percent(10, 4);
            Assert.AreEqual(-1, result);
        }

        [TestMethod]
        [ExpectedException(typeof(DivideByZeroException))]
        public void DivideByZeroIsThrownWithZeroTotal()
        {
            _lib.Percent(8, 0);
        }

    }
}
